package vno.fux.res.pool
{
	import flash.display.BitmapData;
	import flash.utils.Dictionary;

	public class AutoAnimeMatrix implements IResoureceDistributor
	{
		private var _bitmapDataMatrix:Vector.<Vector.<BitmapData>>;
		private var _recievers:Dictionary;
		public function AutoAnimeMatrix()
		{
		}
		public function get matrix():Vector.<Vector.<BitmapData>>
		{
			return _bitmapDataMatrix;
		}
		public function set matrix(value:Vector.<Vector.<BitmapData>>):void
		{
			if(_recievers)
			{
				refreshChildren(value);
			}
			_bitmapDataMatrix = value;
		}
		private function refreshChildren(value:Vector.<Vector.<BitmapData>>):void
		{
			for each(var child:IResourceAttacher in _recievers)
			{
				child.recieve(value);
			}
		}
		public function attach(reciever:IResourceAttacher):void
		{
			if(!_recievers)
			{
				_recievers = new Dictionary(true);
			}
			if(_bitmapDataMatrix)
			{
				reciever.recieve(_bitmapDataMatrix)
			}
			_recievers[reciever] = reciever;
		}
		
		public function detach(child:IResourceAttacher):Boolean
		{
			return delete _recievers[child];
		}
		public function detachAll():void
		{
			_recievers = null;
		}
	}
}